/**
 * Created by Administrator on 2015/12/29.
 */
"use strict";
var _ = require('underscore');
var F = require('../../../common/function');
var C = require('../../../config/index');
var _o2oServiceApi = require('../../../common/o2oServiceApi');
var o2oServiceApi = new _o2oServiceApi;

exports.validateFields = function (obj,key_validate_array){
  let error_msg = '';
  for (let p of key_validate_array) {
    if (typeof ( obj [p]) != " function ") {
      if (obj[p] == undefined || _.isEmpty(_.str.trim(obj[p]))) {
        error_msg += p + ' is undefined or empty,';
      } else if (_.v.isIn(p, ['money','applicableGte'])) {
        if (!_.v.isFloat(obj[p])) {
          error_msg += p + ' is not a valid float number,';
        }
      }else if (_.v.isIn(p, ['vendorid','circulation','applicableUser','offLineTtime','onLineTime'])) {
        if (!_.v.isInt(obj[p])) {
          error_msg += p + ' is not valid integer,';
        }
      }
    }
  }
  if (error_msg != '') {
    error_msg += 'please check.';
  }
  return error_msg;
};